<?php
require_once('./includes/headers.inc.php');

$error = FALSE;
$email = FALSE;
$success = FALSE;

if($_POST) {
    if($userMgr->exists($_POST['email'])) {
        $ret = $msgMgr->sendPasswordResetMail($_POST['email']);
        if($ret) {
            $error = $msgMgr->get('password-reset-success');
        } else {
            $error = $msgMgr->get('password-reset-error');
        }
    } else {
        $error = $msgMgr->get('user-exist-error');
    }
}

$replaces = array(
    'email'             => $email,
    'error'             => $msgMgr->formatMsg($error),
);
$lang = array(
    'header_forgotpassword'     => $langMgr->get('header_forgotpassword'),
    'text_forgotpassword_intro' => $langMgr->get('text_forgotpassword_intro'),
    'text_email'                => $langMgr->get('text_email'),
    'btn_submit'                => $langMgr->get('btn_submit'),
);
$templateMgr->loadContent(basename(__FILE__, '.php'), array_merge($replaces, $lang));
?>
